
<?php
$screen = Blyn::app()->getUIManager()->getCurrentScreen();
$url = $control->getAjaxLinkUrl('saveVender', NULL, array(
    'eventId' => $eventId,
    'venderId' => $venderId));
$updateId = $control->getAjaxContainerId();
?>
<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "addVenderForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<script type="text/javascript">
// this script for collecting the form data and pass to the controller action and doing the on success validations
    function saveVender() {

        var formData = new FormData($("#addVenderForm")[0]);
        $.ajax({
            url: '<?php echo $url; ?>',
            type: 'POST',
            data: formData,
            //datatype: 'json',
            // async: false,
            beforeSend: function() {
                $("#ajax-loaderdiv").show();
            },
            success: function(html) {
                // on success do some validation or refresh the content div to display the uploaded images 
                jQuery("#<?php echo $updateId; ?>").html(html);
            },
            complete: function() {
                $("#ajax-loaderdiv").hide();
            },
            error: function(data) {
                alert("There may a error on uploading. Try again later");
            },
            cache: false,
            contentType: false,
            processData: false
        });

        return false;
    }
</script>
<legend>
    <h4>
        <?php echo $control->getAjaxLink(array('name' => '活动列表', 'id' => 'showEventList')); ?>\
        <?php echo $control->getAjaxLink(array('name' => '供应商列表', 'id' => 'showVenderList'), array('eventId' => $eventId)); ?>\
        <?php echo '新增供应商'; ?>
    </h4>
</legend>
<div class="tabbable tabs-right" style="margin-top: 15px;"> <!-- Only required for left/right tabs -->
    <ul class="nav nav-tabs" style="margin-bottom: 15px">
        <li class="active"><a href="#tab1" data-toggle="tab"><?php echo '供应商信息'; ?></a></li>       
        <li class=""><a href="#tab2" data-toggle="tab"><?php echo '供应商分类'; ?></a></li>       
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab1" style="min-height: 180px">                
            <?php
            $control1 = new BUIControl('addVenderInfo');
            $control1->addRenderView('addVenderInfo', 'vender_add_info', array(
                'eventId' => $eventId,
                'venderId' => $venderId
            ));
            $control1->render();
            ?>  
        </div>  
        <div class="tab-pane" id="tab2" style="min-height: 180px">                
            <?php
            $control2 = new BUIControl('addVenderCategory');
            $control2->addRenderView('addVenderCategory', 'vender_add_category', array(
                'eventId' => $eventId,
                'venderId' => $venderId
            ));
            $control2->render();
            ?>  
        </div> 
    </div>
</div>
<?php
$this->endWidget();
//echo CHtml::endForm();
?>
<button class="btn" onclick="javascript:saveVender()"><?php echo '保存' ?></button>
